package com.example.opentransaction;

import com.alibaba.druid.pool.DruidDataSource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

//开启事务支持
@EnableTransactionManagement
//声明式事务指定
@ImportResource("classpath:transaction.xml")

@MapperScan("com.example.opentransaction.dao")
@SpringBootApplication
public class OpentransactionApplication {
/*
    @Value("${spring.datasource.url}")
    String url;

    @Value("${spring.datasource.username}")
    String username;
    @Value("${spring.datasource.password}")
    String password;

    @Bean
    public DataSource getDataSource(){
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }

 */

    public static void main(String[] args) {
        SpringApplication.run(OpentransactionApplication.class, args);
    }

}
